home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: May 2000
- //
- //
- //
- // Procedure Name:
- // fluidsVerifyGrid
- //
- // Description:
- // Verifies that selected fluids have either static or
- // dynamic (as appropriate) grids for the $current
- // property. Values of $current are expected to be UI
- // names of paintable fluid attributes, such as those
- // listed in the $paintProperties array below. We do
- // it this way, since it's also ok to pass in
- // combinations of these attributes, as in
- // "colorAndDensity".
- //
- // Return Value:
- // "true" if property $current is set to either static or
- // dynamic grid. $makeGridCmd is unchanged.
- //
- // "false" if property $current is not set to either static or
- // dynamic grid. $makeGridCmd[0] contains the MEL command
- // to set active fluids to dynamic grid. $makeGridCmd[1] is
- // the MEL command to make them static.
- //
- global proc int activeFluidsVerifyGrid( string $current,
- string $makeGridCmd[] )
- //
- // Description:
- // For active fluids, call fluidsVerifyGrid.
- //
- {
- int $result = true;
-
- string $selectedFluids[] = `getActiveFluidShapes`;
- if( size( $selectedFluids ) > 0 ) {
- for( $fluid in $selectedFluids ) {
- if( !fluidsVerifyGrid( $fluid, $current, $makeGridCmd ) ) {
- $result = false;
- }
- }
- }
-
- return $result;
- }
-
-
- global proc int fluidsVerifyGrid( string $fluid,
- string $current,
- string $makeGridCmd[] )
- {
- $current = tolower( $current );
-
- string $ctx = `currentCtx`;
- int $ok = true;
-
- // These are the settings for the artFluidAttrCtx cmd.
- // Note that we don't worry about combinations of properties
- // (like "colorAndDensity" since we'll test those individually
- // based on matching the single property name.
- //
- // When adding a paint property here, make sure the lengths of
- // all four arrays are kept in sync.
- //
- string $paintProperties[] = { "density",
- "color",
- "temperature",
- "fuel",
- "velocity",
- "textureCoordinates" };
-
- // These are the fluid attribute names to check for grid status for
- // the above corresponding paint context properties.
- //
- string $fluidAttributes[] = { ".densityMethod",
- ".colorMethod",
- ".temperatureMethod",
- ".fuelMethod",
- ".velocityMethod",
- ".coordinateMethod" };
-
- // The min/max numeric value for each of the above fluid attributes
- // that corresponds to a Grid valued-attribute. Notice for
- // attributes that don't support static grids (fuel and textureCoords)
- // we're just using a value that's the same as the dynamic value.
- //
- int $staticValues[] = { 1, // densityMethod
- 1, // colorMethod
- 1, // temperatureMethod
- 2, // fuelMethod
- 1, // velocityMethod
- 1 }; // textureCoordinates
-
- int $dynamicValues[] = { 2, // densityMethod
- 2, // colorMethod
- 2, // temperatureMethod
- 2, // fuelMethod
- 2, // velocityMethod
- 1 }; // textureCoordinates
-
- // Keep track of the commands we might need to
- // execute for static/dynamic grids individually. (We'll
- // need one or the other depending on the response from
- // the confirm box below.)
- //
- string $createDynamic;
- string $createStatic;
-
- int $i = 0;
- int $numMatches = 0;
-
- for( ; $i < size( $paintProperties ); $i++ ) {
- if( size( match( tolower($paintProperties[$i]), tolower($current) ) ) ) {
- int $method = eval( "getAttr " + $fluid + $fluidAttributes[$i] );
- $numMatches++;
-
- // This property is already set to grid.
- //
- if(( $method == $staticValues[$i] )
- || ( $method == $dynamicValues[$i] ))
- {
- continue;
- }
-
- $ok = false;
-
- // The static value is the same as the dynamic value --
- // only show "Dynamic Grid" option
- //
- if(( $staticValues[$i] != $dynamicValues[$i] )) {
- $createStatic = $createStatic + ( "setAttr " +
- $fluid +
- $fluidAttributes[$i] +
- " " +
- $staticValues[$i] + "; " );
- }
-
- $createDynamic = $createDynamic + ( "setAttr " +
- $fluid +
- $fluidAttributes[$i] +
- " " +
- $dynamicValues[$i] + "; " );
- }
- }
-
- // If they're painting combinations (color + density,
- // for instance) then we're just going to make it easier
- // on ourselves and forget about the fact that color doesn't
- // really have a "static grid" mode by removing the "set static"
- // option from the confirm box.
- //
- if( $numMatches > 1 ) {
- $createStatic = "";
- }
-
- $makeGridCmd[0] = $makeGridCmd[0] + $createDynamic;
- $makeGridCmd[1] = $makeGridCmd[1] + $createStatic;
-
- return $ok;
- }
-
-